
function isIsomorphic(s, t){
    let sToTMap = {}
    let tToSMap = {}
    
    for (let i = 0; i < s.length; i++) {
        const charS = s[i];
        const charT = t[i];

        if(sToTMap[charS]){
            if (sToTMap[charS] !== charT) {
                return false;
            }
        }else{
            sToTMap[charS] = charT
        }
        
        if (tToSMap[charT]) {
            if (tToSMap[charT] !== charS) {
                return false;
            }
        } else {
            tToSMap[charT] = charS;
        }

    }
    return true;
}

// 测试示例
console.log(isIsomorphic("egg", "add")); // true
console.log(isIsomorphic("foo", "bar")); // false
console.log(isIsomorphic("paper", "title")); // true
console.log(isIsomorphic("ab", "aa")); // false